package com.example.servicedemo;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button bt1 =(Button) findViewById(R.id.button);
        Button bt2 =(Button) findViewById(R.id.button2);
        bt2.setOnClickListener((v)->{
            Intent intent = new Intent(MainActivity.this, RandomService.class);
            stopService(intent);
        });
        bt1.setOnClickListener((v)->{
            Intent intent = new Intent(MainActivity.this, RandomService.class);
            startService(intent);
        });
    }
}